package com.youlu.campus.web.cs;

import com.youlu.campus.entity.PlatformConfig;
import com.youlu.campus.service.platform.PlatformConfigService;
import com.youlu.campus.service.platform.PointPlatformConfigService;
import com.youlu.campus.web.common.base.RequestContext;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CsController {
    @Autowired
    private PlatformConfigService platformConfigService;

    @Autowired
    private PointPlatformConfigService pointPlatformConfigService;

    /**
     * 获取客服信息
     *
     * @return
     */
    @GetMapping("/mini-app/cs-info")
    public QResult getCsInfo() {
        String platform = RequestContext.getCurPlatform();
        switch (platform) {
            case "qq":
                PlatformConfig platformConfig = platformConfigService.find();
                return QResult.success(platformConfig.getCsDesc());
            default:
                break;
        }
        return QResult.success("");
    }

    @GetMapping("/mini-app/cs-info/qq")
    public QResult getCsInfoByQq() {
        return QResult.success(pointPlatformConfigService.findCsByAppIdAndPlatform(RequestContext.getAppId(),
                RequestContext.getCurPlatform()));
    }

    @GetMapping("/mini-app/cs-info/qq-v2")
    public QResult getCsInfoByQqV2() {
        return QResult.success(pointPlatformConfigService.findCsByAppIdAndPlatform_V2(RequestContext.getAppId(), RequestContext.getCurPlatform()));
    }

}
